package com.yxuan.springboot.controller;

import com.yxuan.springboot.model.TestAnswer;
import com.yxuan.springboot.model.TestOptions;
import com.yxuan.springboot.model.TestRecords;
import com.yxuan.springboot.service.TestAnswerService;
import com.yxuan.springboot.service.TestOptionsService;
import com.yxuan.springboot.service.TestRecordsService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.sql.Timestamp;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * 
 * @author zchao
 *   TestRecords控制器
 * @date 2023-05-16 14:22:56
 */
@Controller
@Slf4j
@Api(tags = "")
@RequestMapping(value = "/testrecords", method = {RequestMethod.POST,RequestMethod.GET})
public class TestRecordsController extends BaseController<TestRecords>{

    @Autowired
    private TestAnswerService testAnswerService;

    @Autowired
    private TestRecordsService testRecordsService;

    @Autowired
    private TestOptionsService testOptionsService;

//    提交测试，创建测试记录
    @RequestMapping("/addtestrecord")
    @ResponseBody
    public HashMap<String,Object> createRecords(@RequestBody TestRecords entity) throws IOException {
        try{
            return testRecordsService.createRecords(entity);
        }catch (Exception e){
            HashMap<String, Object> result = new HashMap<>();
            log.error(e.getMessage());
            result.put("result",ERROR);
            return result;
        }
    }


//    查看测试结果,根据测试记录id

}
